faApp.controller('blindateListCtrl', ['$cookieStore','$scope','$routeParams','blindateService','$location', '$controller','$route', function($cookieStore,$scope,$routeParams,blindateService, $location, $controller,$route) {
	$controller('BaseListCtrl', {
		$scope: $scope
	});

	$scope.config = {
		pageNo:1,
		PageSize:20
	};
	$scope.editQunName = false;
	$scope.editData = {};
	$scope._id = ''; //传入的id

	$scope.$watch('config', function() {
		blindateService.getDataList($scope.config).then(function(json){
			if(json.statusCode){
				alert('出错了'+json.statusCode)
			}else{
				$scope.list = json.list;
				$scope.pager = json.pager;
			};
		})
	}, true);

	$scope.showHask = function(id,v){
		$scope.editQunName = true;
		$scope._id = id;
		$scope.editData.wechatGroup = v;
	};

	$scope.edit = function(type,id){
		$scope.editData.id = id;	

		if ($scope.editData.wechatGroup) {
			$scope.editData.isJoinWechat = 1; //已加入
		} else {
			$scope.editData.isJoinWechat = 0; //未加入
		};

		blindateService.dateUpdata($scope.editData).then(function(json) {
			if (json.statusCode) {
				alert('出错了');
			} else {
				$scope.editQunName = false;
				blindateService.getDataList($scope.config).then(function(json){
					if(json.statusCode){
						alert('出错了'+json.statusCode)
					}else{
						$scope.list = json.list;
						$scope.pager = json.pager;
					};
				})
			}
		});
	};


	$scope.orderby = function(v) {
		if (v == 'createDate') {
			$scope.config.orderParameter = '01';
		} else if (v == 'updateDate') {
			$scope.config.orderParameter = '02';
		} else if (v == 'playNum') {
			$scope.config.orderParameter = '03';
		};
		if ($scope.config.orderType == '01') {
			$scope.config.orderType = '02';
		} else {
			$scope.config.orderType = '01';
		}

	};

}]);

